/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 *
 * @author A0077454
 */
@Entity
public class PaymentVoucher implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long voucherId;
    private String voucherNum;
    @ManyToOne
    private StockOrder stockOrder;
    @OneToOne(cascade = {CascadeType.PERSIST}, mappedBy="voucher")
    private GoodReceipt goodReceipt;
    @ManyToOne(cascade = {CascadeType.PERSIST})
    private Supplier supplier;
    private String contactPerson;
    private String phone;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private Address address;
    private Double amountDue;
    private Double amountPaid;
    private Boolean approved;
    private Integer paymentPeriod;
    private String specialTerm;
    private Long approvedUserId;
    private String status;
    @OneToMany(cascade = {CascadeType.PERSIST})  
    private List<Transaction> transactions = new ArrayList();
    @OneToOne(cascade = {CascadeType.PERSIST})
    private SystemUser createdBy;

    public PaymentVoucher() {  
    }
     
    public void create( String voucherNum, String contactPerson, String phone, Address address, Double amountDue, Double amountPaid, Boolean approved, Integer paymentPeriod, String specialTerm, Long approvedUserId, String status, Date createdDate) {
        this.voucherNum = voucherNum;
        this.contactPerson = contactPerson;
        this.phone = phone;
        this.address = address;
        this.amountDue = amountDue;
        this.amountPaid = amountPaid;
        this.approved = approved;
        this.paymentPeriod = paymentPeriod;
        this.specialTerm = specialTerm;
        this.approvedUserId = approvedUserId;
        this.status = status;
    }
    
    


    public Boolean getApproved() {
        return approved;
    }

    public void setApproved(Boolean approved) {
        this.approved = approved;
    }

    public List<Transaction> getTransactions() {
        return transactions;
    }

    public void setTransactions(List<Transaction> transactions) {
        this.transactions = transactions;
    }

    
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
    
    public String getVoucherNum() {
        return voucherNum;
    }

    public void setVoucherNum(String voucherNum) {
        this.voucherNum = voucherNum;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getContactPerson() {
        return contactPerson;
    }

    public void setContactPerson(String contactPerson) {
        this.contactPerson = contactPerson;
    }
       

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public Double getAmountDue() {
        return amountDue;
    }

    public void setAmountDue(Double amountDue) {
        this.amountDue = amountDue;
    }

    public Double getAmountPaid() {
        return amountPaid;
    }

    public void setAmountPaid(Double amountPaid) {
        this.amountPaid = amountPaid;
    }

    public boolean isApproved() {
        return approved;
    }

    public void setApproved(boolean approved) {
        this.approved = approved;
    }

    public Long getApprovedUserId() {
        return approvedUserId;
    }

    public void setApprovedUserId(Long approvedUserId) {
        this.approvedUserId = approvedUserId;
    }

    public SystemUser getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(SystemUser createdBy) {
        this.createdBy = createdBy;
    }

   

    public GoodReceipt getGoodReceipt() {
        return goodReceipt;
    }

    public void setGoodReceipt(GoodReceipt goodReceipt) {
        this.goodReceipt = goodReceipt;
    }

    public Integer getPaymentPeriod() {
        return paymentPeriod;
    }

    public void setPaymentPeriod(Integer paymentPeriod) {
        this.paymentPeriod = paymentPeriod;
    }

    public String getSpecialTerm() {
        return specialTerm;
    }

    public void setSpecialTerm(String specialTerm) {
        this.specialTerm = specialTerm;
    }

    public StockOrder getStockOrder() {
        return stockOrder;
    }

    public void setStockOrder(StockOrder stockOrder) {
        this.stockOrder = stockOrder;
    }

    public Supplier getSupplier() {
        return supplier;
    }

    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    public Long getVoucherId() {
        return voucherId;
    }

    public void setVoucherId(Long voucherId) {
        this.voucherId = voucherId;
    }
    
    

   
    @Override
    public String toString() {
        return "Entity.Payment_Voucher[ id=" + voucherId + " ]";
    }
    
    
    //// THINN CHANGES /////
    public void addTransaction(Transaction transaction)
    {
        this.transactions.add(transaction);
    }
}
